<template>
  <!-- <button @click="testApp">testApp</button>
  <Person ref="personRef"
   msg1="aa" msg="bb"
   :perList="persons"
   /> -->
  <ul>
    <li>
      <RouterLink replace to="/ws" activeClass="active">WS</RouterLink>
    </li>
    <li>
      <RouterLink replace to="/" activeClass="active">主页</RouterLink>
    </li>
    <li>
      <RouterLink replace :to="{ path: '/about' }" activeClass="active">关于</RouterLink>
    </li>
    <li>
      <!-- 默认是push、replace不能回退 -->
      <RouterLink replace to="/news" activeClass="active">新闻</RouterLink>
    </li>
    <li>
      <RouterLink replace to="/videos" activeClass="active">视频</RouterLink>
    </li>
    <li>
      <RouterLink replace to="/tongxin" activeClass="active">通信</RouterLink>
    </li>
    <li>
      <RouterLink replace to="/other" activeClass="active">其他</RouterLink>
    </li>
    <li>
      <RouterLink replace to="/redirectDemo" activeClass="active">重定向示例</RouterLink>
    </li>
    <li>
      <!-- https://www.w3schools.com/Css/css_dropdowns.asp -->
      <div class="dropdown">
        <button class="dropbtn">CSS 学习示例</button>
        <div class="dropdown-content">
          <RouterLink replace to="/css1" activeClass="active">Css1</RouterLink>
        </div>
      </div>
    </li>
  </ul>
  <RouterView></RouterView>
</template>

<script lang="ts" setup>
// vue3 的语法
import { ref, reactive } from 'vue';
import Person from './components/Person.vue';
import { type Persons } from '@/types';

defineOptions({
  name: 'App'
})
let personRef = ref()
const testApp = () => {
  console.log(personRef.value)
  console.log(personRef.value.name)
  console.log(personRef.value.title1)
}

const persons = reactive<Persons>([
  { id: '11', name: "李四", age: 20 },
  { id: '22', name: "王五", age: 22 }
]);
</script>

<style scoped>
.app {
  background-color: #ddd;
  box-shadow: 0 0 10px;
  border-radius: 10px;
  padding: 20px;
}

ul {
  li {
    display: inline-block;
    margin-right: 10px;
  }
}

.active {
  color: orange;
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropbtn {
  background-color: #4CAF50;
  color: white;
  padding: 10px;
  font-size: 16px;
  border: none;
  cursor: pointer;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: #f9f9f9;
  min-width: 160px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  z-index: 1;

  a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
  }

  a:hover {
    background-color: #f1f1f1;
  }
}

.dropdown:hover .dropdown-content {
  display: block;
}

.dropdown:hover .dropbtn {
  background-color: #3e8e41;
}
</style>
